package com.mkx.samples;

import com.mkx.structurals.decorator.*;

/**
 * 装饰器模式演示类
 * 演示如何动态地为对象添加额外的功能
 */
public class DecoratorDemo {
    public static void main(String[] args) {
        System.out.println("===== 装饰器模式演示 =====");
        
        // 创建具体构件
        Component component = new ConcreteComponent();
        System.out.println("原始构件操作：");
        component.operation();
        
        // 使用具体装饰器A装饰构件
        Component decoratorA = new ConcreteDecoratorA(component);
        System.out.println("装饰器A装饰后：");
        decoratorA.operation();
        
        // 使用具体装饰器B装饰构件
        Component decoratorB = new ConcreteDecoratorB(component);
        System.out.println("装饰器B装饰后：");
        decoratorB.operation();
        
        // 使用多个装饰器组合装饰构件
        Component decoratorAB = new ConcreteDecoratorA(new ConcreteDecoratorB(component));
        System.out.println("装饰器A和B组合装饰后：");
        decoratorAB.operation();
        
        System.out.println("装饰器模式演示完成\n");
    }
}